using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Daniel.Core.Models.Mapping
{
    public class ExternalAuthenticationRecordMap : EntityTypeConfiguration<ExternalAuthenticationRecord>
    {
        public ExternalAuthenticationRecordMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            // Table & Column Mappings
            this.ToTable("ExternalAuthenticationRecord");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.CustomerId).HasColumnName("CustomerId");
            this.Property(t => t.Email).HasColumnName("Email");
            this.Property(t => t.ExternalIdentifier).HasColumnName("ExternalIdentifier");
            this.Property(t => t.ExternalDisplayIdentifier).HasColumnName("ExternalDisplayIdentifier");
            this.Property(t => t.OAuthToken).HasColumnName("OAuthToken");
            this.Property(t => t.OAuthAccessToken).HasColumnName("OAuthAccessToken");
            this.Property(t => t.ProviderSystemName).HasColumnName("ProviderSystemName");

            // Relationships
            this.HasRequired(t => t.Customer)
                .WithMany(t => t.ExternalAuthenticationRecords)
                .HasForeignKey(d => d.CustomerId);

        }
    }
}
